package com.zhuyp.spring.boot;

import java.util.Date;
import java.util.concurrent.Callable;

import com.zhuyp.spring.boot.entity.User;

public class CallableImpl implements Callable<User> {
	
	private User user;
	private String taskNum;
	
	public CallableImpl(User user,String taskNum) {
		this.user = user;
		this.taskNum = taskNum;
	}

	@Override
	public User call() throws Exception {
		System.out.println(">>>" + taskNum + "任务启动");
		Date dateTmp1 = new Date();
		Thread.sleep(1000);
		Date dateTmp2 = new Date();
		long time = dateTmp2.getTime() - dateTmp1.getTime();
		System.out.println(">>>" + taskNum + "任务终止");
		user.setName(taskNum + "任务返回运行结果,当前任务时间【" + time + "毫秒】");
		return user;
	}
}
